import 'package:example/app/modules/login_module/widget/edit_text_view.dart';
import 'package:flutter/material.dart';
import 'package:example/index.dart';

import 'components/search_content.dart';
import 'components/search_keywords.dart';
import 'search_controller.dart';

class SearchPage extends GetView<SearchController> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: EditTextView(
          controller: controller.searchController,
          widget: Get.screenWidth * 0.8,
          height: 35.dp,
          borderRadius: 35.dp,
          backgroundColor: '#eeeeee'.c,
          hintText: '支持多个关键字, 用空格隔开',
          hintStyle: appLoginModulesHintTextStyle,
          textStyle: appLoginModulesContentTextStyle,
          keyboardType: TextInputType.text,
          maxLines: 1,
          leftIcon: Icon(
            Icons.search_outlined,
            color: Colors.grey,
            size: 24.dp,
          ),
          rightIcon: Icon(
            Icons.close,
            color: Colors.grey,
            size: 24.dp,
          ),
          rightClick: () {
            controller.searchController.clear();
            controller.keywords.value = '';
          },
          textInputAction: TextInputAction.search,
          onSubmitted: (v) {},
          onChange: (v) {
            controller.keywords.value = v;
          },
        ),
        titleSpacing: 0,
      ),
      body: Stack(
        children: [
          Obx(() {
            return Visibility(
              child: SearchKeywords(),
              visible: !controller.showContent.value,
            );
          }),
          Obx(() {
            return Visibility(
              visible: controller.showContent.value,
              child: SearchContent(),
            );
          })
        ],
      ),
    );
  }
}
